<template>
	<div class="content">
		<p style="height: 30rpx;"></p>
		<div class="list_box">	
			<div class="list">
				<div class="name_box">
					<p class="label" v-if="msg.type == 0">卖公司</p>
					<p class="label" v-if="msg.type == 1">卖个体户</p>
					<p class="label" v-if="msg.type == 2">卖代账户</p>
					<span>{{msg.name}}</span>
				</div>
				<!-- 卖公司 -->
				<div class="msg" v-if="msg.type == 0">
					<div>
						<p class="title">{{msg.area}}</p>
						<p class="text">注册地</p>
					</div>
					<div>
						<p class="title">{{msg.setTime}}</p>
						<p class="text">成立时间</p>
					</div>
					<div>
						<p class="title" v-if="msg.taxCredit == 0">不确定</p>
						<p class="title" v-if="msg.taxCredit == 1">A级</p>
						<p class="title" v-if="msg.taxCredit == 2">B级</p>
						<p class="title" v-if="msg.taxCredit == 3">M级</p>
						<p class="title" v-if="msg.taxCredit == 4">C级</p>
						<p class="title" v-if="msg.taxCredit == 5">D级</p>
						<p class="text">纳税等级</p>
					</div>
					<div>
						<p class="title" v-if="msg.bankTatement == 0">不确定</p>
						<p class="title" v-if="msg.bankTatement == 1">流水很多</p>
						<p class="title" v-if="msg.bankTatement == 2">流水偏少</p>
						<p class="title" v-if="msg.bankTatement == 3">连续流水</p>
						<p class="title" v-if="msg.bankTatement == 4">无流水</p>
						<p class="text">流水情况</p>
					</div>
				</div>
				<!-- 卖个体户 -->
				<div class="msg" v-if="msg.type == 1">
					<div>
						<p class="title">{{item.area}}</p>
						<p class="text">注册地</p>
					</div>
					<div>
						<p class="title">{{msg.setTime}}</p>
						<p class="text">成立时间</p>
					</div>
					<div>
						<p class="title" v-if="msg.taxationState == 0">未开业</p>
						<p class="title" v-if="msg.taxationState == 1">小规模</p>
						<p class="title" v-if="msg.taxationState == 2">一般纳税人</p>
						<p class="text">税务</p>
					</div>
					<div>
						<p class="title">{{msg.bankAccount == 0?'未开户':'已开户'}}</p>
						<p class="text">银行</p>
					</div>
				</div>
				<!-- 卖代账户 -->
				<div class="msg" v-if="msg.type == 2">
					<div style="width: 33%;">
						<p class="title">{{item.area}}</p>
						<p class="text">注册地</p>
					</div>
					<div style="width: 33%;">
						<p class="title">{{msg.setTime}}</p>
						<p class="text">成立时间</p>
					</div>
					
					<div style="width: 33%;">
						<p class="title">{{msg.proxyAccount}}</p>
						<p class="text">代账户数</p>
					</div>
				</div>
				<p class="text1">{{msg.remark?msg.remark:''}}</p>
				<div class="price_box">
					<p class="price">售价：
						<span v-if="msg.price">{{msg.price}}元</span>
						<span v-else>面议</span>
					</p>
					<p class="time">{{msg.createTime}}</p>
				</div>
			</div>
		</div>

		<div class="msg_box">
			<div class="title_box">
				<p class="line"></p>
				<p class="title">基本信息</p>
			</div>
			<div class="msg">
				<p class="text"><span>公司名称：</span>{{msg.name}}</p>
				<p class="text"><span>成立时间：</span>{{msg.setTime}}</p>
				<p class="text"><span>注册资本：</span>
					<span v-if="msg.capital == 0">{{msg.capitalAmount}}万元（已实缴）</span>
					<span v-else>未实缴</span>
				</p>
				<p class="text"><span>注册地：</span>重庆</p>
				<p class="text"><span>经营范围：</span>{{msg.businessScope?msg.businessScope:'未填写'}}</p>
			</div>
			<div class="title_box">
				<p class="line"></p>
				<p class="title">税务信息</p>
			</div>
			<div class="msg">
				<p class="text"><span>税务状态：</span>
					<span v-if="msg.taxationState == 0">未开业</span>
					<span v-if="msg.taxationState == 1">小规模</span>
					<span v-if="msg.taxationState == 2">一般纳税人</span>
				</p>
			</div>
			<div class="title_box">
				<p class="line"></p>
				<p class="title">银行信息</p>
			</div>
			<div class="msg">
				<p class="text"><span>账户：</span>{{msg.bankAccount == 0?'未开户':'已开户'}}</p>
			</div>
			<div class="title_box">
				<p class="line"></p>
				<p class="title">资质许可（含高企、认证）</p>
			</div>
			<div class="msg">
				 <p v-for="(item,index) in msg.quaLabelList">{{item.title}}</p>
				<p class="text" v-if="!msg.quaLabelList.length">无</p>
			</div>
		</div>

		<div class="anniu_box">
			<div class="box" :style="{paddingBottom:isIphoneXnum+'px'}">
				<button class="anniu" open-type="share">
					<img src="/static/fx.png" alt="">
					<p>分享</p>
				</button>
				<p @click="toUser" class="an">联系发布人</p>
				<p @click="toGuarantee" class="an">担保交易</p>
			</div>
		</div>
	</div>
</template>

<script>
	import { mapState } from 'vuex'
	import api from '@/api';
	import { Debounce } from '@/utils/utils.js'
	import Config from '@/config/index.js'
	import { formatDateYearMonth } from '@/utils/utils.js'
	export default {
		data() {
			return {
				list1: [{
                    name: '卖公司',
                }, {
                    name: '卖个体户',
                }, {
                    name: '卖代账户',
                }],
				isIphoneXnum:0,
				id:'',
				msg:{},
				shareUserId:'',
			}
		},
		computed: {
			...mapState({
				userId: state => state.user.userId,
				token: state => state.user.token
			})
		},
		methods: {

			// 获取详情
			getXq(){
				api.user.get_company_detail({id:this.id}).then(res=>{
					if(res.code == 200){
						res.data.createTime = formatDateYearMonth(res.data.createTime)
						this.msg = res.data
					}
				})
			},

			// 联系发布人
			toUser(){
				if(!this.token){
					uni.navigateTo({
						url: `/pages/authorization/index?shareUserId=${this.shareUserId}`
					});
					return
				}
				if(this.msg.userId == this.userId){
					this.$toast('不能给自己发私信！')
					return
				}
				let setData = JSON.stringify({
					memberUserId:this.msg.userId,
					id:this.msg.id,
					bAvatar: this.msg.avatar || '/static/mr_tx.png',
					memberUserName:this.msg.userName
				})
				uni.navigateTo({
					url: `/pages/chat/index?setData=${setData}`
				});
			},

			// 担保交易
			toGuarantee(){
				if(!this.token){
					uni.navigateTo({
						url: `/pages/authorization/index?shareUserId=${this.shareUserId}`
					});
					return
				}
				uni.navigateTo({
					url: `/pages/guarantee/index`
				});
			}
			
		},
		onLoad(options) {
			this.id = options.id

			if(options.shareUserId){
				this.shareUserId = options.shareUserId
			}
			this.getXq()
		},
		onShow(){
			uni.getSystemInfo({
				success: (res) => {
					console.log("手机信息res" + res.model);
					let modelmes = res.model;
					if (
						modelmes.search("iPhone 16") != -1 ||
						modelmes.search("iPhone 15") != -1 ||
						modelmes.search("iPhone 14") != -1 ||
						modelmes.search("iPhone 13") != -1 ||
						modelmes.search("iPhone 12") != -1 ||
						modelmes.search("iPhone 11") != -1 ||
						modelmes.search("iPhone X") != -1 ||
						modelmes.search("iPhone XR") != -1 ||
						modelmes.search("iPhone XS") != -1
					) {
						this.isIphoneXnum = 25;
					} else {
						this.isIphoneXnum = 0;
					}
				},
			});
		},
		onShareAppMessage() {
			return {
				title: '免费用万人接单群',
				path: `/pages/company/xq/index?shareUserId=${this.userId}`
			}
		},
	}
</script>

<style lang="scss" scoped>
	.content{
		min-height: 100vh;
		background: #f7f7f7;
		.list_box{
			margin: 0 30rpx;
			.list{
				padding:32rpx 24rpx;
				background: #fff;
				border-radius: 12rpx;
				margin-bottom:20rpx;
				.name_box{
					display: flex;
					align-items: center;
					.label{
						display: inline-block;
						font-size:24rpx;
						color:#fff;
						padding:4rpx 14rpx;
						background: #23AC39;
						border-radius: 16rpx 0 16rpx 0;
						margin-right:10rpx;
					}
					span{
						color: #333333;
						font-size: 30rpx;
						font-weight: 500;
					}
				}
				.msg{
					display: flex;
					justify-content: space-between;
					background: #F6F7F9;
					padding:32rpx 0;
					margin:24rpx 0;
					.title{
						color:#666666;
						font-size:30rpx;
					}
					.text{
						color:#999999;
						font-size:24rpx;
						margin-top:20rpx;
					}
					div{
						width: 25%;
						border-right:1px solid #EEEEEE;
						display: flex;
						flex-direction:column;
						align-items: center;
						&:last-child{
							border-right:none;
						}
					}
				}
				.text1{
					color: #333333;
					font-size: 28rpx;
				}
				.price_box{
					display: flex;
					align-items: center;
					justify-content: space-between;
					margin-top:48rpx;
					.price{
						font-size: 28rpx;
						color:#FF463F;
						span{
							font-size:34rpx;
						}
					}
					.time{
						color: #999999;
						font-size: 26rpx;
					}
				}
			}
		}
		.msg_box{
			padding:24rpx;
			padding-top:0;
			background: #fff;
			margin:0 30rpx;
			border-radius: 12rpx;
			.title_box{
				display: flex;
				align-items: center;
				padding-top:30rpx;
				.line{
					width: 3px;
					height: 9px;
					background: #23AC39;
					margin-right:16rpx;
				}
				.title{
					color: #333333;
					font-size: 32rpx;
					font-weight: 500;
				}
			}
			.msg{
				margin-left:46rpx;
				p{
					margin-top:30rpx;
					font-size:28rpx;
					color:#333333;
					span{
						color:#666666;
					}
				}
			}
		}
		.anniu_box{
			width: 100%;
			height: 150rpx;
			.box{
				width: 92%;
				height: 150rpx;
				position: fixed;
				bottom:0;
				left: 0;
				padding:0 30rpx;
				z-index: 100;
				display: flex;
				align-items: center;
				justify-content: space-between;
				background: #FFFFFF;
				box-shadow: 0px 0px 10px 0px rgba(0, 0, 0, 0.15);
				.an{
					width: 46%;
					height: 96rpx;
					line-height: 96rpx;
					background: linear-gradient(270deg, #62CE73 0%, #23AC39 100%);
					border-radius: 100rpx;
					text-align: center;
					color: #fff;
					font-size: 32rpx;
					font-weight: 500;
					margin-right:20rpx;
					&:last-child{
						margin-right:0;
						background: linear-gradient(270deg, #FF6562 0%, #FF4441 100%);
					}
				}
				
			}
		}
		button{
			background: none;
			border:none;
			padding:0 !important;
			width: 100rpx;
			color:#999999;
			font-size:26rpx;
			line-height: 40rpx;
			margin-right:20rpx;
			&::after{
				border:none;
			}
			img{
				width: 36rpx;
				height: 36rpx;
				margin-right:6rpx;
			}
		}
		
	}
</style>
